REFACTOR: Promote printer dimension defaults (width / blur_radius / font_size) to ClassVar on printer base - #1969
Closed
Roman Lutz (romanlutz) wants to merge 1 commit into
Conversation
Move the hard-coded ``width = 100`` and ``blur_radius = 20`` defaults out of every printer constructor in ``pyrit/output/`` onto ``PrinterBase`` as ``DEFAULT_WIDTH: ClassVar[int]`` and ``DEFAULT_BLUR_RADIUS: ClassVar[int]``. Subclass constructors use the sentinel-default pattern (``width: int | None = None`` resolved via ``self.DEFAULT_*``); ``helpers.py`` forwards ``None`` through and lets the printer resolve the default. No value changes. No behaviour changes. Verified: ruff / ty / pytest pyrit/output/. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Richard Lundeen (rlundeen2)
approved these changes
Jun 9, 2026
Contributor
Author
|
Closing per maintainer feedback on the constants-audit work. This PR introduced the sentinel-default pattern (changing Branch left intact in case any portion is worth cherry-picking later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes printer dimension defaults (
width = 100,blur_radius = 20) from per-constructor hard-coded literals toClassVar[int]attributes onPrinterBaseinpyrit/output/base.py:DEFAULT_WIDTH: ClassVar[int] = 100DEFAULT_BLUR_RADIUS: ClassVar[int] = 20Subclass constructors now use the sentinel-default pattern (
width: int | None = None, resolved toself.DEFAULT_WIDTHat the point of consumption). Docstrings referenceDEFAULT_WIDTH/DEFAULT_BLUR_RADIUS(with the value in parentheses).This is part of the ongoing constants-audit cleanup (continuation of the pattern established in #1964 and #1965).
Scope
Touched only
pyrit/output/:base.py— addedDEFAULT_WIDTHandDEFAULT_BLUR_RADIUSClassVars onPrinterBase.attack_result/pretty.py,attack_result/markdown.pyconversation/pretty.py,conversation/markdown.pyscenario_result/pretty.pyscore/pretty.pyhelpers.py—output_attack_asyncandoutput_conversation_asyncnow takeblur_radius: int | None = Noneand forwardNoneto the printer (printer sentinels resolve the default).Notes
font_size = 15default in printer files, but there are nofont_sizereferences anywhere inpyrit/output/. (Thefont_size = 15hits in the repo are inpyrit/prompt_converter/, out of scope for this PR.) OnlyDEFAULT_WIDTHandDEFAULT_BLUR_RADIUSare promoted here.widthandblur_radiusdefaults inpyrit/output/were already consistent (100 and 20 respectively) — no diverging values to preserve.No value changes. No behaviour changes.
Verified:
ruff check pyrit/output/,ty check pyrit/output/,pytest tests/unit/output/(173 passed).